// Includes
#include "Camera.h"

#ifdef _WIN32
#include <windows.h>		// Include windows header on the windows platform
#endif
#include <GL/gl.h>		// OpenGL header
#include <GL/glu.h>		// OpenGL Utility header

namespace EraAstral
{
	namespace graphics
	{
		// Camera class constructor
		Camera::Camera()
		{
			// Allocate heap memory for world paramters
			m_position = new Vector3();
			m_target = new Vector3();
		}
		
		// Camera class destructor
		Camera::~Camera()
		{
			// Delete world parameters
			delete m_position;
			delete m_target;
		}
		
		// Apply transformations to the 3D scene
		void Camera::ApplyTransforms()
		{
			// Calculate view matrix
			gluLookAt(m_position->X, m_position->Y, m_position->Z,			// Position
						m_target->X, m_target->Y, m_target->Z,				// Look at
						0.0f, 1.0f, 0.0f);									// Up vector
		}
		
		// Gets the position of the camera
		Vector3 *Camera::GetPosition() const
		{
			return m_position;
		}
		
		// Sets the position of the camera
		void Camera::SetPosition(const Vector3& position)
		{
			m_position->Set(position);
		}
		
		// Gets the target position of the camera
		Vector3 *Camera::GetTarget() const
		{
			return m_target;
		}
		
		// Sets the target position of the camera
		void Camera::SetTarget(const Vector3& target)
		{
			m_target->Set(target);
		}
	}
}
